﻿using AnyLink.PosClient;
using AnyLink.PosClient.View;
using AnyLink.PosClient.ViewModel;

namespace Microsoft.Extensions.DependencyInjection
{
    /// <summary>
    /// 为View提供扩展方法
    /// </summary>
    public static class ViewExtenssions
    {
        /// <summary>
        /// 注册View
        /// </summary>
        /// <param name="services"></param>
        public static void AddView(this IServiceCollection services)
        {
            services.AddSingleton<MainWindow>();
            services.AddSingleton<MainPage>();
            services.AddSingleton(sp => new MainWin
            {
                DataContext = sp.GetRequiredService<MainViewModel>(),
                //MainFrame.Content = sp.GetRequiredService<MainPage>(), // 设置默认页面
                //MainFrame.Navigate(new Uri("SubPage.xaml", UriKind.Relative))
            });
            services.AddSingleton(sp => new LoginWin { DataContext = sp.GetRequiredService<LoginViewModel>() });
            services.AddSingleton(sp => new SaleWin { DataContext = sp.GetRequiredService<SaleViewModel>() });
        }
    }
}
